
<template>
    <rx-dialog @handOk="cancel" :oktext="$ti18('rxForm.closeBtn','关闭')" :showcancel="false">
        <rx-layout>
            <div slot="center">
                <a-form-model ref="form"  :model="mdl" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
                  <a-row>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.subject','记录标题')" prop = "subject">
                        {{mdl.subject}}
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.listName','列表名称')" prop = "listName">
                        {{mdl.listName}}
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.status','导入状态')" prop = "status">
                        <a-tag :color="statusMap[mdl.status].color">
                          <span>{{ statusMap[mdl.status].text }}</span>
                        </a-tag>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.createByName','创建人名称')" prop = "createByName">
                        {{mdl.createByName}}
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :span="24">
                      <a-form-model-item   :label="i18n('form.log','记录日志')" prop = "content" :label-col="labelCol1" :wrapper-col="wrapperCol1">
                        <rx-grid ref="table"
                                 :dataSource="contentAry"
                                 :showPage="true"
                                 :bordered="true"
                                 :columns="contentColumns"
                                 style="height:463px;"
                        >
                        </rx-grid>
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                </a-form-model>
            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
    import FormImportRecordApi from '@/api/form/core/formImportRecord'
    import {RxDialog,BaseFormModel,RxGrid} from "@lowcode/jpaas-common-lib";


    export default {
        name: 'FormImportRecordEdit',
        mixins:[BaseFormModel],
        components: {
            RxDialog,
            RxGrid
        },
        data(){
            return {
                statusMap: {
                    1: {color: 'green', text: this.i18n('statusMap.success','成功')},
                    0: {color: 'red', text: this.i18n('statusMap.fail','失败')},
                    2: {color: 'orange', text: this.i18n('statusMap.importing','正在导入')}
                },
              contentAry:[],
              contentColumns:[
                {
                  title: this.i18n('form.batchGroup','批次组'),
                  dataIndex: 'index',
                  width: 60
                },
                {
                  title: this.i18n('form.exeResult','执行结果'),
                  dataIndex: 'content',
                  width: 200
                },
              ]
            }
        },
        methods: {
            i18n(name,text,key){
                return this.$ti18(name,text,"FormImportRecord",key);
            },
            onload_(values){
                if(values){
                  this.contentAry=JSON.parse(values.content || '[]').sort(function (a, b) {
                    return a['index'] - b['index'];
                  });
                }
            },
            get(id){
                return FormImportRecordApi.get(id);
            },

            save(){
                return FormImportRecordApi.save(this.mdl);
            },

        }
    }
</script>
<style>
    .relick a{
        margin-right: 10px;
    }

</style>
